<?php
if (get_magic_quotes_gpc()) {
    function magicQuotes_awStripslashes(&$value, $key) {$value = stripslashes($value);}
    $gpc = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    array_walk_recursive($gpc, 'magicQuotes_awStripslashes');
}

require '../lib/facebook.php';

// http://fql-builder.mariogarcia.biz/
$facebook = new Facebook(array(
  'appId'  => 'yourAppId',
  'secret' => 'yourAppSecret',
));

// Get User ID
$user = $facebook->getUser();

if($_GET['code'] && $_GET['state']){
    header('Location: ../');
    exit;
}

$params['scope']=$_GET['perms'];  
$loginUrl = $facebook->getLoginUrl($params);
header('Location: '.$loginUrl);
// echo "<a href='$loginUrl'>Log In</a>"; 
